package com.eastfair.certificate.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 用户填写的制证信息
 * </p>
 *
 * @author ligang
 * @date 2023-07-07
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "CertificateUserDataResourceEnum", description = "数据来源:#{CENTIFICATE:制证;E:E展览;-枚举")
public enum CertificateUserDataResourceEnum implements BaseEnum {

    /**
     * CENTIFICATE="制证"
     */
    CENTIFICATE("制证"),
    /**
     * E="E展览"
     */
    E("E展览"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static CertificateUserDataResourceEnum match(String val, CertificateUserDataResourceEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static CertificateUserDataResourceEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(CertificateUserDataResourceEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "CENTIFICATE,E", example = "CENTIFICATE")
    public String getCode() {
        return this.name();
    }

}
